import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'home',
    component: () => import('../views/HomeView.vue'),
    alias: "/home",
    redirect: 'recommend',
    children: [{
        path: 'mustSee',
        name: 'mustSee',
        component: () => import('../views/mustSee.vue')
      },
      {
        path: 'hot',
        name: 'hot',
        component: () => import('../views/hot.vue'),
        
      },
    
      {
        path: 'recommend',
        name: 'recommend',
        component: () => import('../views/Recommend.vue'),

      },
      {
        path: 'cateRecommend',
        name: 'cateRecommend',
        component: () => import('../views/cateRecommend.vue')
      },
      {
        path: 'selection',
        name: 'selection',
        component: () => import('../views/selection.vue')
      },
    ]
  },
  {
    path: '/handnote',
    name: 'handnote',
    component: () => import('../views/HandNote.vue')

  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/Search.vue')
  },
  {
    path: '/my',
    name: 'my',
    component: () => import('../views/My.vue')
  },
  {
    path: '/video',
    name: 'video',
    component: () => import('../views/Video.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/searchdetail',
    name: 'searchdetail',
    component: () => import('../views/SearchDetail.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/searchresult',
    name: 'searchresult',
    component: () => import('../views/SearchResult.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/notedetail',
    name: 'notedetail',
    component: () => import('../views/noteDetail.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/hotclass',
    name: 'hotclass',
    component: () => import('../views/hotClass.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/hotselect',
    name: 'hotselect',
    component: () => import('../views/hotSelect.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/hotrecommend',
    name: 'hotrecommend',
    component: () => import('../views/hotRecommend.vue'),
    meta:{
      notShowTab:true
    },
  },
  {
    path: '/banner',
    name: 'banner',
    component: () => import('../views/banner.vue'),
    meta:{
      notShowTab:true
    },
  }

]

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  },

})
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router